home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWGOrderedVector.z / RWGOrderedVector
Encoding:
Text File  |  2002-10-03  |  10.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                  RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWGOrderedVector(val) - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/gordvec.h>
  13.  
  14.  
  15.  
  16.               declare(RWGVector,val)
  17.           declare(RWGOrderedVector,val)
  18.           implement(RWGVector,val)
  19.           implement(RWGOrderedVector,val)
  20.           RWGOrderedVector(val) v;// Ordered vector of objects of val val.
  21.  
  22.  
  23.  
  24.  
  25. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  26.      Class RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) represents an ordered collection of objects
  27.      of val vvvvaaaallll.  Objects are ordered by the order of insertion and are
  28.      accessible by index.  Duplicates are allowed.  RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) is
  29.      implemented as a vector, using macros defined in the standard C++ header
  30.      file <<<<ggggeeeennnneeeerrrriiiicccc....hhhh>>>>.  Note that it is a vvvvaaaalllluuuueeee----bbbbaaaasssseeeedddd collection: items are
  31.      copied in and out of the collection.  The class vvvvaaaallll must have:
  32.           a default constructor;
  33.  
  34.           well-defined copy semantics (vvvvaaaallll::::::::vvvvaaaallll((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or equiv.);
  35.  
  36.           well-defined assignment semantics (vvvvaaaallll::::::::ooooppppeeeerrrraaaattttoooorrrr====((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or
  37.           equiv.);
  38.  
  39.           well-defined equality semantics (vvvvaaaallll::::::::ooooppppeeeerrrraaaattttoooorrrr========((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or
  40.           equiv.).
  41.  
  42.      To use this class you must declare and implement its base class as well
  43.      as the class itself.  For example, here is how you declare and implement
  44.      an ordered collection of doubles:.Ex
  45.          declare(RWGVector,double)                     // Declare base class
  46.  
  47.  
  48.  
  49.               declare(RWGOrderedVector,double)  // Declare ordered vector
  50.           // In one and only one .cpp file you must put the following:
  51.           implement(RWGVector,double)            // Implement base class
  52.           implement(RWGOrderedVector,double)     // Implement ordered vector
  53.  
  54.  
  55.      For each val of RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr you must include one (and only one) call
  56.      to the macro iiiimmmmpppplllleeeemmmmeeeennnntttt somewhere in your code for both the
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                  RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr itself and for its base class RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr.
  75.  
  76. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  77.      None
  78.  
  79. EEEExxxxaaaammmmpppplllleeee
  80.      Here's an example that uses an ordered vector of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggs.
  81.  
  82.               #include <rw/gordvec.h>
  83.           #include <rw/cstring.h>
  84.           #include <rw/rstream.h>
  85.           declare(RWGVector,RWCString)
  86.           declare(RWGOrderedVector,RWCString)
  87.           implement(RWGVector,RWCString)
  88.           implement(RWGOrderedVector,RWCString)
  89.           main()  {
  90.             RWGOrderedVector(RWCString) vec;
  91.             RWCString one("First");
  92.             vec.insert(one);
  93.             vec.insert("Second");   // Automatic val conversion occurs
  94.             vec.insert("Last");     // Automatic val conversion occurs
  95.             for(size_t i=0; i<vec.entries(); i++)  cout << vec[i] << endl;
  96.             return 0;
  97.           }
  98.  
  99.  
  100.      Program output:
  101.  
  102.               First
  103.           Second
  104.           Last
  105.  
  106. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  107.               RWGOrderedVector(val)(size_t capac=RWDEFAULT_CAPACITY);
  108.  
  109.  
  110.      Construct an ordered vector of elements of val vvvvaaaallll.  The initial capacity
  111.      of the vector will be ccccaaaappppaaaacccc whose default value is RRRRWWWWDDDDEEEEFFFFAAAAUUUULLLLTTTT____CCCCAAAAPPPPAAAACCCCIIIITTTTYYYY.
  112.      The capacity will be automatically increased as necessary should too many
  113.      items be inserted, a relatively expensive process because each item must
  114.      be copied into the new storage.
  115.  
  116. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  117.               val
  118.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i) const;
  119.           val&
  120.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
  121.  
  122.  
  123.      Return the iiiith value in the vector.  The index iiii must be between 0 and
  124.      one less than the number of items in the vector.  No bounds checking is
  125.      performed.  The second variant can be used as an lvalue, the first
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                  RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      cannot.
  141.  
  142.               val
  143.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i) const;
  144.           val&
  145.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
  146.  
  147.  
  148.      Return the iiiith value in the vector.  The index iiii must be between 0 and
  149.      one less than the number of items in the vector.  Bounds checking will be
  150.      performed.  The second variant can be used as an lvalue, the first
  151.      cannot.
  152.  
  153.               void
  154.           cccclllleeeeaaaarrrr();
  155.  
  156.  
  157.      Remove all items from the collection.
  158.  
  159.               const val*
  160.           ddddaaaattttaaaa() const;
  161.  
  162.  
  163.      Returns a pointer to the raw data of self.  Should be used with care.
  164.  
  165.               size_t
  166.           eeeennnnttttrrrriiiieeeessss() const;
  167.  
  168.  
  169.      Return the number of items currently in the collection.
  170.  
  171.               size_t
  172.           iiiinnnnddddeeeexxxx(vvvvaaaallll item) const;
  173.  
  174.  
  175.      Perform a linear search of the collection returning the index of the
  176.      first item that iiiissssEEEEqqqquuuuaaaallll to the argument iiiitttteeeemmmm.  If no item is found, then
  177.      it returns RRRRWWWW____NNNNPPPPOOOOSSSS.
  178.  
  179.               void
  180.           iiiinnnnsssseeeerrrrtttt(vvvvaaaallll item);
  181.  
  182.  
  183.      Add the new value iiiitttteeeemmmm to the end of the collection.
  184.  
  185.               void
  186.           iiiinnnnsssseeeerrrrttttAAAAtttt(size_t indx, vvvvaaaallll item);
  187.  
  188.  
  189.      Add the new value iiiitttteeeemmmm to the collection at position iiiinnnnddddxxxx.  The value of
  190.      iiiinnnnddddxxxx must be between zero and the length of the collection.  No bounds
  191.      checking is performed.  Old items from index iiiinnnnddddxxxx upwards will be shifted
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                  RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      to higher indices.
  207.  
  208.               RWBoolean
  209.           iiiissssEEEEmmmmppppttttyyyy() const;
  210.  
  211.  
  212.      Returns TTTTRRRRUUUUEEEE if the collection has no entries.  FFFFAAAALLLLSSSSEEEE otherwise.
  213.  
  214.               void
  215.           ssssiiiizzzzeeee____tttt
  216.           lllleeeennnnggggtttthhhh() const;
  217.  
  218.  
  219.      Synonym for eeeennnnttttrrrriiiieeeessss(((()))).
  220.  
  221.               vvvvaaaallll
  222.           ppppoooopppp();
  223.  
  224.  
  225.      Removes and returns the last item in the vector.
  226.  
  227.               vvvvooooiiiidddd
  228.           ppppuuuusssshhhh(val);
  229.  
  230.  
  231.      Synonym for iiiinnnnsssseeeerrrrtttt(((()))).
  232.  
  233.               rrrreeeemmmmoooovvvveeeeAAAAtttt(size_t indx);
  234.  
  235.  
  236.      Removes the item at position iiiinnnnddddxxxx from the collection.  The value of iiiinnnnddddxxxx
  237.      must be between zero and one less than the length of the collection.  No
  238.      bounds checking is performed.  Old items from index iiiinnnnddddxxxx++++1111 will be
  239.      shifted to lower indices.  E.g...., the item at index iiiinnnnddddxxxx++++1111 will be moved
  240.      to position iiiinnnnddddxxxx, etc.
  241.  
  242.               void
  243.           rrrreeeessssiiiizzzzeeee(size_t newCapacity);
  244.  
  245.  
  246.      Change the capacity of the collection to nnnneeeewwwwCCCCaaaappppaaaacccciiiittttyyyy, which must be at
  247.      least as large as the present number of items in the collection.  Note
  248.      that the actual number of items in the collection does not change, just
  249.      the capacity.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.